<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/9/11 0011
  Time: 20:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fnt" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE HTML>
<%
    String path = request.getContextPath();
    pageContext.setAttribute("path", path);
%>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="${path}/manage/js/lib/html5shiv.js"></script>
    <script type="text/javascript" src="${path}/manage/js/lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="${path}/manage/css/static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="${path}/manage/css/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="${path}/manage/js/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="${path}/manage/css/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="${path}/manage/css/static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" type="text/css" href="${path}/manage/js/lib/layer/2.4/skin/layui.css" />
    <link rel="stylesheet" type="text/css" href="${path}/manage/js/lib/laydate/theme/default/laydate.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="${path}/manage/js/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script type="text/javascript" src="${path}/manage/js/lib/layer/2.4/skin/font/iconfont.ttf"></script>
    <script type="text/javascript" src="${path}/manage/js/lib/layer/2.4/skin/font/iconfont.woff"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>添加考试</title>
</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i>
    首页
    <span class="c-gray en">&gt;
</span> 考试管理
    <span class="c-gray en">&gt;</span> 组织考试
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
        <i class="Hui-iconfont">&#xe68f;</i>
    </a>
</nav>
<article class="page-container">
    <form class="form form-horizontal" id="form-admin-add">
        <!--添加考试信息-->
        <div class="first-set">
            <h2 style="margin-left: 150px;margin-bottom: 50px;color: #555555;">第一步&nbsp;&nbsp;&nbsp;&nbsp;添加考试信息</h2>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>设置考题标题：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" placeholder="">
                    <input type="hidden" class="hidden-title-id">
                </div>
            </div>
            <div class="row cl">
                 <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>设置考试开始时间：</label>
                <div class="layui-inline">
                    <div class="layui-input-block">
                        <input name="beginTimeFrom" type="text" autocomplete="off" id="startTime" class="layui-input laydate">
                    </div>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>设置考试结束时间：</label>
                <div class="layui-inline">
                    <div class="layui-input-block">
                        <input name="beginTimeTo" type="text" autocomplete="off" id="endTime" class="layui-input laydate">
                    </div>
                </div>
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" id="first-set" value="&nbsp;&nbsp;下一步&nbsp;&nbsp;">
                </div>
            </div>
        </div><br>

        <!--设置考题结构-->
        <div style="margin-top: 50px;display: none;" class="second-set">
            <h2 style="margin-left: 150px;margin-bottom:50px;color: #555555;">第二步&nbsp;&nbsp;&nbsp;&nbsp;设置考题结构</h2>
                 <c:forEach items="${categorys}" var="category" varStatus="stat">

                     <div class="row cl">
                         <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                              ${category.categoryName}设置:
                                <input type="hidden" value="${category.id}" name="categoryId">
                                <div class="btn btn-primary radius" id="jia${category.id}">+</div>
                                <input style="width: 70px;" class="btn btn-primary radius" name="categorySum" value="0"/>
                                <div class="btn btn-primary radius" id="del${category.id}">-</div>
                             道
                             &nbsp;&nbsp;&nbsp;&nbsp;
                             分值: <c:forEach items="${configList}" var="config" varStatus="stat">
                                    <c:if test="${config.key=='single_grade'&&category.id==1}">
                                        <input style="width: 70px;" class="btn btn-primary radius" id="jia${category.id}" value="${config.value}"/>&nbsp;&nbsp;分
                                    </c:if>
                                  <c:if test="${config.key=='choice_grade'&&category.id==3}">
                                      <input style="width: 70px;" class="btn btn-primary radius" id="jia${category.id}" value="${config.value}"/>&nbsp;&nbsp;分
                                  </c:if>
                                  <c:if test="${config.key=='judge_grade'&&category.id==4}">
                                      <input style="width: 70px;" class="btn btn-primary radius" id="jia${category.id}" value="${config.value}"/>&nbsp;&nbsp;分
                                  </c:if>
                              </c:forEach>
                         </div>
                     </div>
                 </c:forEach>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    设置总分为:<input class="btn btn-primary radius" id="grade-sum" style="margin-right: 200px;"value="0">
                </div>
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" id="second-prev-set" style="margin-right: 200px;"value="&nbsp;&nbsp;上一步&nbsp;&nbsp;">
                    <input class="btn btn-primary radius" id="second-next-set" value="&nbsp;&nbsp;下一步&nbsp;&nbsp;">
                </div>
            </div>
        </div>
        <!--添加考试人员-->
        <div style="margin-top: 50px;display: none;" class="three-set">
            <h2 style="margin-left: 150px;margin-bottom: 50px;color: #555555;">第三步&nbsp;&nbsp;&nbsp;&nbsp;添加考试人员</h2>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <span class="l">
                        <a href="javascript:;" onclick="member_add('添加用户','/manage/examination/formal-user','','510')" class="btn btn-primary radius">
                            <i class="Hui-iconfont">&#xe600;</i>
                            添加用户
                        </a>
                        <a href="javascript:;" id="select-user" class="btn btn-primary radius">
                            <i class="Hui-iconfont">&#xe600;</i>
                            查看选中用户
                        </a>
                    </span>
                </div>
            </div>
            <div class="mt-20">

            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" style="margin-right: 200px;" id="three-set-prev" value="&nbsp;&nbsp;上一步&nbsp;&nbsp;">
                    <a href="/manage/examination/examination-message-list">
                        <input class="btn btn-primary radius" id="three-set-finish" value="&nbsp;&nbsp;完成&nbsp;&nbsp;">
                    </a>
                </div>
            </div>
        </div>
    </form>
</article>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="${path}/manage/js/lib/question-type/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="${path}/manage/js/lib/layer/2.4/layer.js"></script>
<%--<script type="text/javascript" src="${path}/manage/js/lib/layer/2.4/skin/layui.js"></script>--%>
<script type="text/javascript" src="${path}/manage/js/lib/laydate/laydate.js"></script>
<script type="text/javascript" src="${path}/manage/css/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="${path}/manage/css/static/h-ui.admin/js/H-ui.admin.js"></script>
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="${path}/manage/js/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="${path}/manage/js/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="${path}/manage/js/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="${path}/manage/js/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="${path}/manage/js/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>


<script type="text/javascript">
    /*用户-添加*/
    function member_add(title,url,w,h){
        var examinationId=$(".hidden-title-id").val();
        url=url+"?examinationId="+examinationId;
        layer_show(title,url,w,h);
    }

    $(function () {
        $('.table-sort').dataTable({
            "aaSorting": [[ 1, "desc" ]],//默认第几个排序
            "bStateSave": true,//状态保存
            "aoColumnDefs": [
                //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                {"orderable":false,"aTargets":[0,8,9]}// 制定列不参与排序
            ]
        });

        //日期
        var nowTime=new Date();
        var startTime=laydate.render({
            elem:'#startTime',
            type:'datetime',
            btns: ['confirm'],
            trigger: 'click',
            min:'nowTime',//默认最大值为当前日期
            done:function(value,date){
                endTime.config.min={
                    year:date.year,
                    month:date.month-1,//关键
                    date:date.date,
                    hours:date.hours,
                    minutes:date.minutes,
                    seconds:date.seconds
                };
            }
        });
        var endTime=laydate.render({
            elem:'#endTime',
            type:'datetime',
            btns: ['confirm'],
            trigger: 'click',
            min:'nowTime',
            done:function(value,date){
                startTime.config.min={
                    year:date.year,
                    month:date.month-1,//关键
                    date:date.date,
                    hours:date.hours,
                    minutes:date.minutes,
                    seconds:date.seconds
                }
            }
        });

        //选中问题类别
        $("div[id^='jia']").click(function () {
            var text=$(this).next().val();
            text++;
            $(this).next().val(text);
            var gradeSum=Number($("#grade-sum").val());
            var grade=Number($(this).next().next().next().val());
            gradeSum=gradeSum+grade;
            $("#grade-sum").val(gradeSum);
        });

        $("div[id^='del']").click(function () {
            var text=$(this).prev().val();
            if(text>0){
                text--;
                $(this).prev().val(text);
                var gradeSum=Number($("#grade-sum").val());
                var grade=Number($(this).next().val());
                gradeSum=gradeSum-grade;
                $("#grade-sum").val(gradeSum);
            }
        });

        //查看选中用户信息
        $("#select-user").click(function () {
            var examinationId=$(".hidden-title-id").val();
            var data={examinationId:examinationId};
            $.ajax({
                url:"/manage/examination/select-examination-user",
                type:"get",
                data:data,
                success:function (mes) {
                    $(".mt-20").html(mes);
                }
            });
        });

        //初始状态，显示第一步,添加问题信息
        //第一步  点击下一步，显示第二步，第一步隐藏
        $("#first-set").click(function () {
            var examinationTitle=$(this).parent().parent().prev().prev().prev().find(".input-text").val();
            var startTime=$("#startTime").val();
            var endTime=$("#endTime").val();
            if(examinationTitle!=""&&startTime!=""&&endTime!=""){
                var data={examinationTitle:examinationTitle,startTime:startTime,endTime:endTime};
                $.ajax({
                    url:"/manage/examination/addExaminationTitle",
                    data:data,
                    type:"post",
                    success:function (mes) {
                        $(".hidden-title-id").val(mes);
                        $(".second-set").css("display","block");
                        $(".first-set").css("display","none");
                    }
                });
            }else{
                alert("内容不能为空!");
            }
        });

        //第二步  点击上一步,显示第一步，第二步隐藏
        $("#second-prev-set").click(function () {
            $(".first-set").css("display","block");
            $(".second-set").css("display","none");
        });
        //第二步  点击下一步，显示第三步，第二步隐藏
        $("#second-next-set").click(function () {
            var categordIds=new Array();
            var listId=$(this).parent().parent().parent().find("input[name=categoryId]");
            listId.each(function () {
                categordIds.push($(this).parent().parent().find("input[name=categoryId]").val());
            });
            categordIds=categordIds.toString();
            var categorySums=new Array();
            var listSum=$(this).parent().parent().parent().find("input[name=categorySum]");
            listSum.each(function () {
                categorySums.push($(this).parent().parent().find("input[name=categorySum]").val());
            });
            categorySums=categorySums.toString();
            var examinationId=$(".hidden-title-id").val();
            var data={categordIds:categordIds,categorySums:categorySums,examinationId:examinationId};
            $.ajax({
                url:"/manage/examination/addTestPaperStructure",
                type:"post",
                data:data,
                success:function(mes){
                    $(".three-set").css("display","block");
                    $(".second-set").css("display","none");
                }
            });
        });
        //第三步  点击上一步,显示第二步，第三步隐藏
        $("#three-set-prev").click(function () {
            $(".second-set").css("display","block");
            $(".three-set").css("display","none");
        });

        //第三步 点击完成，到考试管理页面
    })
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>